package com.rams.ls.gui.form;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;

import net.miginfocom.layout.CC;
import net.miginfocom.layout.LC;
import net.miginfocom.swing.MigLayout;

import com.rams.ls.Config;

public class FormItems extends BasicForm {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1762781950373424583L;

	private static final JToolBar toolbar = new JToolBar();
	private static final JList itemsList = new JList();
	
	private static Map<String, JButton> btnsMap = new HashMap<String, JButton>();
	
	public FormItems() {
		this.setLayout(new MigLayout(new LC().debug(Config.debug).fill().wrap()));
		
		initToolbar();
		
		add(toolbar, new CC().spanY().growY());
	}
	
	private void initBtns() {
		btnsMap.put("armor", new JButton("Armor"));
		btnsMap.put("res", new JButton("Resource"));
		btnsMap.put("potion", new JButton("Potion"));
		btnsMap.put("scrolls", new JButton("Scrolls"));
		btnsMap.put("weapon", new JButton("Weapon"));
	}
	
	private void initToolbar() {
		initBtns();
		
		toolbar.setFloatable(false);
		toolbar.setOrientation(SwingConstants.VERTICAL);
		
		Iterator<String> i = btnsMap.keySet().iterator();
		while (i.hasNext()) {
			toolbar.add(btnsMap.get(i.next()), new CC().growX().spanX());
		}
	}
}
